package com.heima.user.controller.v1;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.user.dtos.ApplyToWemediaDto;
import com.heima.model.user.dtos.CheckRegisterDto;
import com.heima.model.user.dtos.LoginDto;
import com.heima.model.user.dtos.RegisterDto;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserService;
import javafx.geometry.Pos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * 用户控制器
 */
@RestController
@RequestMapping("/api/v1/login")
public class ApUserController {
    @Autowired
    private ApUserService apUserService;

    /**
     * 登录
     */
    @PostMapping("/login_auth")
    public ResponseResult<Map<String,Object>> login(@RequestBody LoginDto dto){
        return apUserService.login(dto);
    }

    @GetMapping ("/findById/{id}")
    public ResponseResult<ApUser> findById(@PathVariable Integer id){
        ApUser user = apUserService.getById(id);
        return ResponseResult.okResult(user);
    }

    /**
     * App注册发送验证码
     */
    @PostMapping("/appSendSMS")
    public ResponseResult appSendSMS(@RequestBody RegisterDto dto){
        return     apUserService.appSendSMS(dto);
    }
    /**
     * App验证码注册校验,注册用户
     */
    @PostMapping("/register")
    public ResponseResult appClientRegister(@RequestBody CheckRegisterDto dto){
        return apUserService.appClientRegister(dto);
    }



    //http://localhost:8801/app/user/api/v1/login/apply_to_become_Wemedia
    @PostMapping("/apply")//apply_to_become_Wemedia
    public ResponseResult apply_to_become_Wemedia(MultipartFile file,ApplyToWemediaDto dto){
        return apUserService.apply_to_become_Wemedia(file,dto);
    }

}
